<?php
require_once('./connexion.php');
require ('../func.req.php');
require('../config/tbl.php');

/*
  -----------------------------------
  ---- SCRIPT D'AUTHENTIFICATION ----
  FujiCraft V3.0
  By Fujido
  Contact : thefujido@gmail.com
  -----------------------------------
 */

@session_start(); // On relaye la session
if (@session_is_registered("authentification")) { // v�rification sur la session authentification (la session est elle enregistr�e ?)
// ici les �ventuelles actions en cas de r�ussite de la connexion
} else {
    header("Location:index.php?erreur=intru"); // redirection en cas d'echec
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title><?php echo $site; ?> | <?php echo $admin; ?> | Configuration du site</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta http-equiv="Content-Style-Type" content="text/css" />
        <meta http-equiv="content-language" content="fr,en" />
        <link rel='shortcut icon' type="image/x-icon" href='../images/favicon.ico' />
        <link rel="stylesheet" type="text/css" href="../css/style.css" title="" media="all" />
        <link rel="stylesheet" type="text/css" href="../css/register.css" title="" media="all" />
    </head>
    <body>
        <?php
// si l'utilisateur est connect� comme admin ...
        if ($_SESSION['privilege'] == "admin") { // Affichage conditionnel : si et seulement si l'utilisateur est connect� avec le privilege administrateur
            ?>
            <div id="block">
                <div id="contentblock">
                    <div class="wrapper">
                        <?php
                        show_header_adm();
                        show_menu_adm();
                        ?>
                        <div class="mainbox">
                            <?php
                            if (isset($_POST['edit_info'])) {
                                $sitename_edit = $_POST['sitename'];
                                $extension_edit = $_POST['extension'];
                                $forum_edit = $_POST['forum'];
                                $map_edit = $_POST['map'];
                                $forum_edit = $_POST['forum'];
                                $live_edit = $_POST['live'];
                                $youtube_edit = $_POST['youtube'];
                                $facebook_edit = $_POST['facebook'];
                                $minecraft_ip_edit = $_POST['minecraft_ip'];
                                $minecraft_port_edit = $_POST['minecraft_port'];
                                $minecraft_version_edit = $_POST['minecraft_version'];
                                $bukkit_edit = $_POST['bukkit'];
                                $ts_ip_edit = $_POST['ts_ip'];
                                $ts_port_edit = $_POST['ts_port'];
                                $mumbles_ip_edit = $_POST['mumble_ip'];
                                $mumble_port_edit = $_POST['mumble_port'];

                                $query = "UPDATE " . $database . "." . $tb_info . " SET sitename_info = '$sitename_edit', extension_info = '$extension_edit', forum_info = '$forum_edit', dynmap_info = '$map_edit', live_info = '$live_edit', youtube_info = '$youtube_edit', facebook_info = '$facebook_edit', serverip_info = '$minecraft_ip_edit', serverport_info = '$minecraft_port_edit', serverversion_info = '$minecraft_version_edit', bukkitversion_info = '$bukkit_edit', tsip_info = '$ts_ip_edit', tsport_info = '$ts_port_edit', mumbleip_info = '$mumbles_ip_edit', mumbleport_info = ' $mumble_port_edit' ";
                                mysql_query($query) OR DIE(mysql_error());
                                ?>
                                <div id="box" onclick="document.getElementById('box').style.display='none';" class="success-box rounded" title="Fermer la fen&ecirc;tre">
                                    Les informations on bien &eacute;t&eacute; &eacute;dit&eacute;es.
                                </div>
                                <br />
                                <br />
                                <a href="./site.php" class="btn">Retourner &agrave; la configuration du site</a> <br />
                                <br />
                                <br />
                                <?php
                            } else {
                                require('../config/tbl.php');
                                ?>
                                <h2>Configuration du site</h2>
                                <br />
                                <center>
                                    <form method="POST" action="<?php $_SERVER['PHP_SELF']; ?>">
                                        <table border="0" cellspacing="0">
                                            <tr>
                                                <td colspan="3" class="title_form">Informations du site</td>
                                            </tr>
                                            <tr>
                                                <td class="text_form">Nom : </td>
                                                <td><input type="text" name="sitename" size="30" value="<?php echo $site; ?>" class="border" /></td>
                                            </tr>
                                            <tr>
                                                <td class="text_form">Extension : </td>
                                                <td><input type="text" name="extension" size="30" value="<?php echo $extension; ?>" class="border" /></td>
                                            </tr>
                                            <tr>
                                                <td class="text_form">Forum : </td>
                                                <td><input type="text" name="forum" size="30" value="<?php echo $forum; ?>" class="border" /></td>
                                            </tr>
                                            <tr>
                                                <td class="text_form">Live : </td>
                                                <td><input type="text" name="live" size="30" value="<?php echo $live; ?>" class="border" /></td>
                                            </tr>
                                            <tr>
                                                <td class="text_form">YouTube : </td>
                                                <td><input type="text" name="youtube" size="30" value="<?php echo $youtube; ?>" class="border" /></td>
                                            </tr>
                                            <tr>
                                                <td class="text_form">Groupe Facebook : </td>
                                                <td><input type="text" name="facebook" size="30" value="<?php echo $facebook; ?>" class="border" /></td>
                                            </tr>
                                            <tr>
                                                <td colspan="3" class="title_form">Serveur Minecraft</td>
                                            </tr>
                                            <tr>
                                                <td class="text_form">Ip du serveur : </td>
                                                <td><input type="text" name="minecraft_ip" size="30" value="<?php echo $host; ?>" class="border" /></td>
                                            </tr>
                                            <tr>
                                                <td class="text_form">Port du serveur : </td>
                                                <td><input type="text" name="minecraft_port" size="30" value="<?php echo $port; ?>" class="border" /></td>
                                            </tr>
                                            <tr>
                                                <td class="text_form">Version du serveur : </td>
                                                <td><input type="text" name="minecraft_version" size="30" value="<?php echo $minecraft; ?>" class="border" /></td>
                                            </tr>
                                            <tr>
                                                <td class="text_form">Version de CraftBukkit : </td>
                                                <td><input type="text" name="bukkit" size="30" value="<?php echo $bukkit; ?>" class="border" /></td>
                                            </tr>
                                            <tr>
                                                <td colspan="3" class="title_form">Serveur vocal</td>
                                            </tr>
                                            <tr>
                                                <td class="text_form">Ip TeamSpeak : </td>
                                                <td><input type="text" name="ts_ip" size="30" value="<?php echo $ts_ip; ?>" class="border" /></td>
                                            </tr>
                                            <tr>
                                                <td class="text_form">Port TeamSpeak : </td>
                                                <td><input type="text" name="ts_port" size="30" value="<?php echo $ts_port; ?>" class="border" /></td>
                                            </tr>
                                            <tr>
                                                <td class="text_form">Ip Mumble : </td>
                                                <td><input type="text" name="mumble_ip" size="30" value="<?php echo $mumble_ip; ?>" class="border" /></td>
                                            </tr>
                                            <tr>
                                                <td class="text_form">Port Mumble : </td>
                                                <td><input type="text" name="mumble_port" size="30" value="<?php echo $mumble_port; ?>" class="border" /></td>
                                            </tr>
                                            <tr>
                                                <td colspan="2" valign="middle" align="center"><input type="submit" name="edit_info" value="Editer" class="btn" /></td>
                                            </tr>
                                        </table>
                                    </form>
                                </center>
                                <br />
                            </div>
                            <?php
                        }
                        show_footer_adm();
                        ?>
                    </div>
                </div>
            </div>
        <?php } ?> <!-- fin de l'affichage conditionnel -->
        <?php
// si l'utilisateur est connect� comme simple utilisateur ...
        if ($_SESSION['privilege'] == "user") { // Affichage conditionnel : si et seulement si l'utilisateur est connect&eacute; avec le privilege utilisateur simple
            header("Location:index.php?erreur=refused"); // redirection si c'est un utilisateur
        }
        ?>
    </body>
</html>
